<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>平方</title>
</head>
<body>
    <input  type="text" id="myseet">
    <input type="button" value="平方" onclick="fn()">
    <div id="mydiv">结果:</div>

    <script>
        function fn(){
            let i = document.getElementById("myseet");
            let d = document.getElementById("mydiv");

            if(isNaN(i.value)){
                d.innerText="输入错误!";
                return;
            }
            // d.innerText = "结果"+i.value*i.value;
            //当字符串进行-*时会自动转换数值
            // d.innerText = "结果:"+(parseInt(i.value)+parseInt(i.value))
            d.innerText = "结果:"+(i.value*1+i.value*1);



        }

    </script>


</body>
</html>